package com.lhn.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;

import java.io.IOException;

/**
 * es 客户端-创建索引
 *
 * @author lhn
 * @date 2022/07/27 22:23
 * @since 1.0.0
 **/
public class ESTest_Doc_Delete {

    public static void main(String[] args) throws IOException {
        RestHighLevelClient restHighLevelClient = null;
        try {
            restHighLevelClient = new RestHighLevelClient(RestClient.builder(new HttpHost("106.15.191.175", 9200, "http")));

            // 修改数据
            DeleteRequest request = new DeleteRequest();

            request.index("user").id("1001");

            DeleteResponse response = restHighLevelClient.delete(request, RequestOptions.DEFAULT);
            System.out.println(request.getDescription());


        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            assert restHighLevelClient != null;
            restHighLevelClient.close();
        }
    }

}